/**
* @file trigger.h
* @brief 触发器
*/
#ifndef _SERVICE_TRIGGER_H_
#define _SERVICE_TRIGGER_H_

#include <stdint.h>
#include "../share/common_singleton.h"
#include "../share/timer.h"
#include "../share/common_singleton.h"
#include <list>

class ITriggerAction
{
public:
	ITriggerAction() {
		eventid_ = 0;
		script_id_ = 0;
	}
	virtual ~ITriggerAction() {}
	void set_eventid(int32_t eventid) { eventid_ = eventid; }
	void set_scriptid(int32_t scriptid) { script_id_ = scriptid; }
	int32_t eventid() { return eventid_; }
	int32_t script_id() { return script_id_; }
protected:
	int32_t eventid_;
	int32_t script_id_;
};

/**
* @brief 时间间隔触发器
*/
class CTimerTrigger : public ITriggerAction, public ::common::CTimer
{
public:
	CTimerTrigger() {}
	~CTimerTrigger() {}

	void TriggerInit(int32_t delta_time, int32_t neventid, int32_t nscript_id);
	void TimerActive();
};

/**
* @brief 时间点触发器
*/
class CTimerPoiontTrigger : public ITriggerAction, public ::common::CTimer
{
public:
	CTimerPoiontTrigger() {
		time_point_ = 0;
	}
	~CTimerPoiontTrigger() {}
	void set_timepoint(int32_t time) { time_point_ = time; }

	//point_time 203010:代表晚上8点30分10秒的时候
	void TriggerInit(int32_t point_time, int32_t neventid, int32_t nscript_id);
	void TimerActive();
private:
	int32_t time_point_;
};


class CTriggerManager : public ::common::CSingleton<CTriggerManager>
{
public:
	CTriggerManager();
	~CTriggerManager();

	void InitTrigger();
private:
	std::list<ITriggerAction*> trigger_list_;
};

#endif

